package org.haifi.game.util;

import java.util.Random;

/**
 * 提供随机数处理等相关工具类
 * 
 * @author joycube2
 * 
 */
public class GameUtil {
	private static Random random = new Random();
	/**
	 * 随机出现的字符
	 */
	private static char[] randomChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
			.toCharArray();

	/**
	 * 获得一个随机大小写字母
	 * 
	 * @return
	 */
	public static char nextChar() {
		return randomChars[nextInt(randomChars.length)];
	}

	/**
	 * 获得一个随机int
	 * 
	 * @return
	 */
	public static int nextInt() {
		return random.nextInt();
	}

	/**
	 * 获得一个以max为上限的随机数，范围 0 ~ max-1
	 * 
	 * @param max
	 * @return
	 */
	public static int nextInt(int max) {
		return random.nextInt(max);
	}
}
